package com.gzz.orchid.context.application.base.convert;

import com.gzz.orchid.context.application.base.command.TempletSaveCmd;
import com.gzz.orchid.context.application.base.pojo.TempletDto;
import com.gzz.orchid.context.application.base.pojo.TempletVo;
import com.gzz.orchid.context.infrastructure.definition.Status;
import com.gzz.orchid.context.infrastructure.persistence.entity.base.BaseTempletPo;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

/**
 * @author higmd
 */
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, imports = {Status.class})
public interface TempletConverter {
    TempletConverter INSTANCE = Mappers.getMapper(TempletConverter.class);

    @Mappings({
            @Mapping(target = "status", expression = "java(Status.parse(po.getStatus()))"),
    })
    TempletVo mapVo(BaseTempletPo po);

    @Mappings({
            @Mapping(target = "status", expression = "java(Status.parse(po.getStatus()))"),
    })
    TempletDto mapDto(BaseTempletPo po);

    void updatePo(@MappingTarget BaseTempletPo po, TempletSaveCmd cmd);
}
